package com.wdd.libbase.base

import com.wdd.libbase.mvp.IPresenter
import dagger.android.AndroidInjection
import javax.inject.Inject

/**
 *
 * @ProjectName:    OwnTool
 * @Package:        com.wdd.libbase.base
 * @ClassName:      BaseMvpActivity
 * @Description:     mvp基类
 * @Author:         王丹丹
 * @CreateDate:     2019/12/9 11:35
 * @UpdateUser:     更新者
 * @UpdateDate:     2019/12/9 11:35
 * @UpdateRemark:   更新说明
 * @Version:        1.0
 */
abstract class BaseMvpActivity<P : IPresenter> : BaseActivity() {
    @Inject
    lateinit var mPresenter: P

    override fun inject() {
        super.inject()
        AndroidInjection.inject(this)
        initLifecycleObserver()
    }

    /**
     * 把mPresenter和activity生命周期绑定，要在initData之前
     */
    protected open fun initLifecycleObserver() {
        mPresenter.setLifecycleOwner(this)
        lifecycle.addObserver(mPresenter)
    }

}